package tictactoe.gameprocessors;

import tictactoe.Client;
import tictactoe.Game;

import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * Created by IntelliJ IDEA.
 * User: Double
 * Date: 15.01.12
 * Time: 21:05
 * To change this template use File | Settings | File Templates.
 */
public class MultiGameProcessor implements Runnable,GameProcessor
{
	private ArrayList<Game> games = new ArrayList<Game>();
	private boolean flag = true;

	public MultiGameProcessor()
	{
		//new Thread(this).start();
	}

	@Override
	public void startGame(Client fclient, Client sclient)
	{
		games.add(new Game(fclient,sclient));
		System.out.println("Currently games: "+games.size());
		Logger.getLogger("TicTacToeServer").log(Level.SEVERE,"Total games:"+games.size());
	}

	@Override
	public void run()
	{
		while(flag)
		{
			System.out.println(games.size());
				for(int i=0;i<games.size();i++)
				{

					games.get(i).checkClients();
				}
			}

	}
}
